package com.wanxi.servlet.other;

import com.wanxi.model.other.BrandModel;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/show1")
public class ShowServlet extends HttpServlet {
    static List<BrandModel> brandModelList=new ArrayList<>();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        if(brandModelList.isEmpty()){
            for (int i = 0; i < 3; i++) {
                BrandModel brandModel=new BrandModel();
                brandModel.setName("三只松鼠");
                brandModel.setEnterPrise("三只松鼠");
                brandModel.setId(i);
                brandModel.setIntroduction("三只松鼠");
                brandModel.setStatus(1);
                brandModelList.add(brandModel);
            }
        }
        req.setAttribute("brandModelList",brandModelList);
        req.getRequestDispatcher("table.jsp").forward(req,resp);
    }
}
